home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11378 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: erich.triumf.ca!bennett
  2. From: bennett@erich.triumf.ca (P.Bennett)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: A little more explanation
  5. Date: 23 Mar 1996 09:45 PST
  6. Organization: TRIUMF: Tri-University Meson Facility
  7. Distribution: world
  8. Message-ID: <23MAR199609455524@erich.triumf.ca>
  9. References: <4iskkm$guk@cti01.citenet.net> <4isl5t$guk@cti01.citenet.net> <4j1018$r6i@cti01.citenet.net>
  10. NNTP-Posting-Host: ftp.triumf.ca
  11. News-Software: VAX/VMS VNEWS 1.50    
  12.  
  13. In article <4j1018$r6i@cti01.citenet.net>, kabir@citenet.net (larry mintz) writes...
  14. >I have the following data in a file called log.dat.It represents the login/out
  15. >times of people on a network:  The fields are
  16. >                  NAME    LOGIN_TIME  LOGOUT_TIME  PORT
  17. >                  urstupid   5:30:12     6:00:00    25
  18.  
  19. >The structure I am using is 
  20. >          struct xx{ char NAME[10];
  21. >>                     char LOGIN_TIME[10];
  22. >                     char  LOGOUT_TIME[10];
  23. >                     unsigned PORT:5;
  24. >                   };
  25.  
  26. >Question: How do I load log.dat into the struct LOGTABLE[10] so all the data 
  27. >is in the proper fields?
  28.  
  29. Try reading a line with fgets(), then separate the pieces with strtok(),
  30. sscanf(), or otherwise.  Perhaps strncpy(), if the fields are of fixed width.
  31.  
  32.  
  33.  
  34. Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
  35. Internet: bennett@triumf.ca         | of one another only when one can be
  36. Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
  37. TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
  38. GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
  39. or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.